package com.administrator.customviewtest.view.search_trans;

import android.animation.ValueAnimator;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.EditText;
import android.widget.TextView;

import com.administrator.customviewtest.R;

/**
 * Created by Administrator on 2017/2/4.
 */

public class SearchSecondAct extends AppCompatActivity {
    private ValueAnimator valueAnimator;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_2);

        float originY = getIntent().getIntExtra("y", 0);

        int location[] = new int[2];
        findViewById(R.id.tv_search_bg).getLocationOnScreen(location);

        float translateY = originY - (float) location[1];

        valueAnimator =  ValueAnimator.ofFloat( translateY);

        valueAnimator.setDuration(1000).start();


        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                findViewById(R.id.tv_search_bg).setY((Float) valueAnimator.getAnimatedValue());
//                mArrowImg.setY(mSearchBGTxt.getY() + (mSearchBGTxt.getHeight() - mArrowImg.getHeight()) / 2);
//                mHintTxt.setY(mSearchBGTxt.getY() + (mSearchBGTxt.getHeight() - mHintTxt.getHeight()) / 2);
//                mSearchTxt.setY(mSearchBGTxt.getY() + (mSearchBGTxt.getHeight() - mSearchTxt.getHeight()) / 2);
            }
        });
    }
}
